<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
    <meta charset="UTF-8">
    <title>图片轮播</title>
    <meta name="page-view-size" content="1280*720">
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/carrousel.css">
    <script type="text/javascript" src="lib/js/evm.js"></script>
    <script type="text/javascript" src="lib/js/Evm_djyw.js"></script>
    <script type="text/javascript" src="lib/js/key.js"></script>
    <script src="lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/api.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
    <div class="btns btn-left"> 《 </div>
    <div class="carrousel-bg" id="carrouselMain">
    </div>
    <div class="btns btn-right"> 》 </div>
</body>
<script>
    var modelIndex = {
        disHeader: true,
        disUser: true,
        isIndex: false,
        index: 0,//初始位置
        listName: 'model', //模块名称
        containerId: 'carrouselMain'//包含模块的标签id
    }
    var direState = false;
    var dataLength;
    var param = {
        id: TV.GetParam('id')
    }
    var apiName = TV.GetParam('type') ||"getArticle";
    // getArticle
    
    GetDatas(apiName, param, function (err, res) {
        console.log(res)
        var mess = res.data;
        if (apiName=="getArticle") {
            var mess={
                images:mess.images,
                img:mess.img
            }
        } else if(apiName=="getActivity"){
            var mess={
                images:mess.photos,
                img:mess.images
            }
        } else if(apiName=="childInfo"){
            var mess={
                img:mess.img
            }
        } else if(apiName=="event" ||apiName=="getVoteOption" ){
            var mess={
                img:mess.img
            }
        }else{
            var mess={
                images:img,
                img:mess.img
            }
        }
        var str = '';
        if (mess.images && mess.images.length != 0) {
            dataLength = mess.images.length;  
            for (var i = 0; i < dataLength; i++) {
                str += ' <div class="model"><img src="' + API_URL.imgURL + mess.images[i] + '"></div>'
            }
        }else if(mess.img){
            if(typeof mess.img == 'string'){
                dataLength = 1;
                str += ' <div class="model"><img src="' + API_URL.imgURL + mess.img + '"></div>'
            }else{
                dataLength = mess.img.length;  
            for (var i = 0; i < dataLength; i++) {
                str += ' <div class="model"><img src="' + API_URL.imgURL + mess.img[i] + '"></div>'
            }
            }
        }else{
            str += ' <div class="model"><img src="/images/nonePic.png"></div>'

        }
            $('#' + modelIndex.containerId).html(str);
            right.toggleFocus( );
            direState = true;
            if (dataLength > 1) {
                $('.btns').css('display', 'block');
                direState = true;
            }
    })
    
    function direOpt(index, directive) {
        console.log(directive,'directive')
        if (directive == "backwards" && direState) { //左
            index = index >= 1 ? --index : dataLength - 1
        } else if (directive == 'forwards' && direState) {  //右
            index = index < dataLength - 1 ? ++index : 0
        }
        return index;
    }
</script>
<script type="text/javascript" src="../js/index.js"></script>

</html>